package cn.tedu.collection;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;

/**
 * @author ：Dsi
 * @date ：2021/11/18 11:18
 * Describe ：该类用于进一步测试List接口
 */
public class TestList02 {
    public static void main(String[] args) {
        List<String> l=new ArrayList<>();
        l.add("喜洋洋");
        l.add("美洋洋");
        l.add("懒洋洋");
        l.add("菲洋洋");
        l.add("哭洋洋");
        l.add("沸洋洋");

        for (int i = 0; i < l.size(); i++) {
            System.out.println(l.get(i));
        }

        for (String a:l
             ) {
            System.out.println(a);
        }
        Iterator<String> i = l.iterator();
        while (i.hasNext()){
            System.out.println(i.next());
        }
        System.out.println();
        ListIterator<String> l2 = l.listIterator();
        while (l2.hasNext()){
            if(!l2.hasNext()){
                System.out.println(l2.previous());
            }
        }

    }
}
